<template>
    <!-- <div v-for="(value,key,index) in objects">{{index}}--{{key}}:{{value}}</div> -->
    <!-- <div v-if="value==23" v-for="(value,key,index) in objects">{{index}}--{{key}}:{{value}}</div> -->
   <!-- <div id="app"> -->
     <!-- <div v-for="dataForm.grossPiece in data">{{dataForm.grossPiece}}</div> -->
  <div class="cert-container">
    <div class="cert-box">
      <table border="1">
        <tr>
          <td colspan="4" class="h-cert-2">
            <div class="cert-title">
              <div class="cert-title-num">ZL/SMP·019</div>
              <div class="cert-title-text">合&nbsp;格</div>
            </div>
          </td>
        </tr>
        <tr>
          <td class="h-cert" colspan="4">
            <div class="m-l-5">物料名称：{{ dataForm.productName }}</div>
          </td>
        </tr>
        <tr>
          <td class="h-cert w-cert-1">
            <div class="m-l-5">物料编码</div>
          </td>
          <td class="h-cert w-cert-2">
            <div class="m-l-5">{{ dataForm.productGmp }}</div>
          </td>
          <td class="h-cert w-cert-3">
            <div class="m-l-5">张&nbsp;&nbsp;数</div>
          </td>
          <!-- <td class="h-cert w-cert-4"><div class="m-l-5">{{ current + '/' + total }}</div></td> -->
          <td class="h-cert w-cert-4">
            <!-- <div class="m-l-5">{{ current + '/' + dataForm.grossPiece }}</div> -->
            <!-- <div class="m-l-5" v-show="false">{{'&nbsp;&nbsp;'+ '/' + dataForm.grossPiece }}</div> -->
            <!-- <div class="m-l-5">{{'&nbsp;&nbsp;'+ '/' + dataForm.grossPiece }}</div> -->
            <div class="m-l-5">/</div>
            </td>
          </td>
        </tr>
        <tr>
          <td class="h-cert w-cert-1">
            <div class="m-l-5">批&nbsp;&nbsp;号</div>
          </td>
          <td class="h-cert w-cert-2">
            <div class="m-l-5">{{ dataForm.batchNum }}</div>
          </td>
          <td class="h-cert w-cert-3">
            <div class="m-l-5">放行日期</div>
          </td>
          <td class="h-cert w-cert-4">
            <div class="m-l-5">{{ dataForm.passDate | changeTime }}</div>
          </td>
        </tr>
        <tr>
          <!--          <td class="h-cert w-cert-1"><div class="m-l-5">有效期至</div></td>
          <td class="h-cert w-cert-2"><div class="m-l-5">{{ changeTime2(dataForm.validityDate, dataForm.selectDateUnit) }}</div></td>
               -->
          <td class="h-cert w-cert-1">
            <div class="m-l-5">有效期/复验期</div>
          </td>
          <td class="h-cert w-cert-2">
            <div class="m-l-5">{{ changeTime2(dataForm.validityDate, dataForm.selectDateUnit) }}{{ changeTime2(dataForm.reinspectDate, dataForm.selectDateUnit) }}</div>
          </td>
          <td class="h-cert w-cert-3">
            <div class="m-l-5">责 任 人</div>
          </td>
          <td class="h-cert w-cert-4">
            <div class="m-l-5">{{ dataForm.passUserName }}</div>
          </td>
        </tr>
      </table>
    </div>
  </div>
  <!-- </div> -->
</template>

<script>
  import {
    getPass
  } from '@/api/check'
  import { CODE_OK } from '@/common/js/config'
  import { isBlank,parseTime } from '@/common/js/utils'
	export default {
    data() {
      return {
        el:"#app",
        visible: false,
        dataForm: {}
      }
    },
    // props: ["childDataForm","current","total"],
    props: ["childDataForm","current","dataForm.grossPiece"],
    created() {
      if (!isBlank(this.childDataForm)) {
        this.getData()
        this.visible = true
      }
    },
    methods: {
      changeTime2(value, flag) {
        let t
        if (value) {
          t = value.split(' ')[0]
          if (flag == 0) {
            return t
          }else{
            return t.substring(0,t.length-3)
          }
        }else{
          return ''
          // return '无'
        }
      },
      getData() {
        const params = {
          checkMergeId: this.childDataForm.checkMergeId
        }
        getPass(params).then(res => {
          if (res.code === CODE_OK) {
            this.dataForm = res.pass
            if (isBlank(this.dataForm.passQuantity)) {
              this.$message.error(this.dataForm.productName+'('+this.dataForm.batchNum+')没有放行数量，自动剔除')
              this.close()
              this.$emit('sub')
            }
          }else{
            this.$message.error(res.msg)
          }
        })
      },
      close() {
        this.visible = false
        this.$emit('close')
      }
    }
	}
</script>

<style type="text/scss" lang="scss" scoped>
  .m-l-5{
    margin-left: 5px;
  }
  .h-cert{
    height: 31px;
    line-height: 1;
  }
  .h-cert-2{
    height: 80px;
  }
  .w-cert-1{
    width: 72px;
  }
  .w-cert-2{
    width: 124px;
  }
  .w-cert-3{
    width: 105px;
  }
  .w-cert-4{
    width: 100px;
  }
  .cert-container{
    font-weight: 900;
    margin-left: 10px;
    color: black;
    background-color: #fff;
    font-family: SimSun;
    font-size: 14px;
    width: 325px;
    .cert-box{
      position: relative;
      .cert-title{
        .cert-title-num{
          position: absolute;
          top: 2px;
          right: 5px;
          font-size: 16px;
          font-family: Arial;
        }
        .cert-title-text{
          position: absolute;
          top: 15px;
          left: 91px;
          font-size: 47px;
          font-weight: bold;
        }
      }
    }
  }
</style>
